window.$config = {
    host : '',
    // host : '/mmp_bak/htdocs',
    url: 'http://h5.oeeee.com/index.php?m=FatherDay&a=index',
    getCookie :function (c_name) {
        if (document.cookie.length>0) {
            var c_start=document.cookie.indexOf(c_name + "=")
            if (c_start!=-1)
            {
                c_start=c_start + c_name.length+1
                var c_end=document.cookie.indexOf(";",c_start)
                if (c_end==-1) c_end=document.cookie.length
                return unescape(document.cookie.substring(c_start,c_end))
            }
        }
        return ""
    },
    IsPC : function () {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
                flag = false;
                break;
            }
        }
        return flag;
    },
    iswx : function(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            return true;
        }else{
            return false;
        }
    },
    wxShare : function(Option) {
        if(!this.iswx()) return;
        var time = setInterval(function () {
            try {
                if (!wx || !oe_wxconfig) return;
            } catch (e) {
                return;
            }

            clearTimeout(time);
            //初始化
            if(!Option) Option={};
            var config = oe_wxconfig,
                title = Option.title ? Option.title : "这个男人，最爱对我撒谎",
                summary = Option.cont ? Option.cont : "他是谁",
                link = Option.url ? Option.url : $config.url,
                thumb = "http://h5.oeeee.com/h5/v17/fqj/logo.jpg",
                content = {
                    title: title,
                    desc: summary,
                    link: link,
                    imgUrl: thumb,
                    type: '',
                    dataUrl: '',
                    success: function () {
                    },
                    cancel: function () {
                    }
                }

            wx.config({
                debug: false,
                appId: config.appId,
                timestamp: config.timestamp,
                nonceStr: config.nonceStr,
                signature: config.signature,
                jsApiList: [
                    'onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo'
                ]
            });
            wx.checkJsApi({
                jsApiList: ['onMenuShareAppMessage', 'onMenuShareTimeline', 'onMenuShareQQ', 'onMenuShareWeibo'],
                success: function (res) {
                }
            });
            wx.ready(function () {
                wx.onMenuShareAppMessage(content);
                wx.onMenuShareTimeline(content);
                wx.onMenuShareQQ(content);
                wx.onMenuShareWeibo(content);
            });
        },500);
    },
    init : function () {
        if(!this.getCookie('wx_h5_wxuid') && location.hostname == 'h5.oeeee.com' && this.iswx()){
            location.href = this.url;
            return;
        }
        if(this.iswx()){
            window.onload = function () {
                var jwx1 = document.createElement('script');
                jwx1.setAttribute('src','http://res.wx.qq.com/open/js/jweixin-1.0.0.js');
                console.log(document.body)
                document.body.appendChild(jwx1);
                var jwx2 = document.createElement('script');
                jwx2.setAttribute('src','https://m.mp.oeeee.com/helper.php?m=WxHelper&a=config&domain=oeeee.com');
                document.body.appendChild(jwx2);
            }
        }
    }
}

$config.init();